package com.cloudkinto.common.web;

import java.util.Collection;
import java.util.Map;

/**
 * @author zhangyy
 * @date 2020 5-9
 */
public class PageResult<T> extends ListResult<T> {

    private static final long serialVersionUID = -5649860845496237556L;

    /**
     * 分页信息
     */
    private PageInfo pageInfo;

    private Map mapInfo;
    private String code;

    /**
     * 无参构造函数
     */
    public PageResult() {
        super();
    }

    public PageResult(Collection<T> values) {
        super(values);
    }

    public PageResult(Collection<T> values, int current, int pageSize, int total, int pageNos) {
        super(values);
        this.code = "200";
        this.pageInfo = new PageInfo();
        this.pageInfo.setCurrent(current);
        this.pageInfo.setPageSize(pageSize);
        this.pageInfo.setTotal(total);
        this.pageInfo.setPageNos(pageNos);
    }

    public PageInfo getPageInfo() {
        return pageInfo;
    }

    public void setPageInfo(PageInfo pageInfo) {
        this.pageInfo = pageInfo;
    }

    public Map getMapInfo() {
        return mapInfo;
    }

    public void setMapInfo(Map mapInfo) {
        this.mapInfo = mapInfo;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String toString() {
        String str = super.toString();
        String pageStr = "";
        if (pageInfo != null) {
            pageStr = pageInfo.toString();
        }
        StringBuilder sb = new StringBuilder();
        sb.append(str).append(",").append(pageStr);
        return sb.toString();
    }


}
